<br>
<div class="panel panel-default shadowed">
    <div class="panel-heading clearfix">
        <h2 class="panel-title pull-left">Areas</h2>
        <div class="pull-right">
            <form class="form">
                <input type="text" class="form-control" ng-model="rsc.searchArea" placeholder="Search...">
            </form>
        </div>
        <div class="pull-right">
            <button type="button" class="btn btn-primary" ng-click="rsc.editResource(undefined, 'editArea', rsc.URLS.AREAS_URL, rsc.RESOURCES.AREAS)"><span class="fa fa-plus"></span> Area</button>
        </div>
    </div>
    <div class="panel-body">
        <table class="table table-hover table-mouse-hover">
            <thead>
            <tr>
                <th>Name</th>
                <th>Description</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="area in rsc.areas| filter: rsc.searchArea" ng-click="rsc.editResource(area, 'editArea', rsc.URLS.AREAS_URL, rsc.RESOURCES.AREAS)">
                <td>{{area.name}}</td>
                <td>{{area.description}}</td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script type="text/ng-template" id="editArea">
    <div class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="editAreaLabel">Edit Area</h4>
                </div>
                <div class="modal-body">
                    <form role="form">
                        <div class="row">
                            <div class="form-group col-md-6">
                                <label for="name">Name</label>
                                <input type="text" ng-model="erc.resource.name" class="form-control" id="name">
                            </div>
                            <div class="form-group col-md-6">
                                <label for="description">Description</label>
                                <input type="text" ng-model="erc.resource.description" class="form-control" id="description">
                            </div>
                        </div>
                    </form>
                    <div class="pull-right">
                        <button type="button" class="btn btn-primary" ng-click="erc.addAreaCity()"><span class="fa fa-plus"> City</span></button>
                    </div>
                    <form role="form">
                        <div class="form-group" ng-repeat="city in erc.resource.area_cities">
                            <div class="row">
                                <div class="form-group col-md-6">
                                    <label for="city-name">City Name</label>
                                    <input type="text" ng-model="city.name" class="form-control" id="city-name">
                                </div>
                                <div class="form-group col-md-2" ng-show="!$first">
                                    <button type="button" style="margin-top: 25px" class="btn btn-danger" ng-click="erc.removeAreaCity($index)"><span class="fa fa-minus"></span></button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning" data-dismiss="modal" ng-click="erc.close('none')">
                        <span class="fa fa-close"></span> Cancel
                    </button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" ng-click="erc.close('update')" ng-show="erc.isDeleteAllowed()">
                        <span class="fa fa-check"></span> Update Area
                    </button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" ng-click="erc.close('add')" ng-show="!erc.isDeleteAllowed()">
                        <span class="fa fa-check"></span> Add Area
                    </button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="erc.close('delete')" ng-show="erc.isDeleteAllowed()">
                        <span class="fa fa-trash"></span> Delete Area
                    </button>
                </div>
            </div>
        </div>
    </div>
</script>